<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
  </head> 
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">员工管理</a>
        <a>
          <cite>服务员管理</cite></a>
      </span>
    </div>
       <div class="layui-row">
          <form class="layui-form layui-col-md12 x-so" action='' method="post" id="addfoods">
        	  <div class="layui-input-inline">
	        	  	<select name="shop_id" >
	        	  		  <option value="0">--全店员工--</option>
		        	  	  {volist name="shopData" id="shop"}
		        	  	      <option value="{$shop.id}">{$shop.shop_name}</option>
		        	  	  {/volist}
		        	  </select>
		        	  
			      </div> 
			      <div class="layui-input-inline">
					      <select name="status">
					      	  <option value="0">--全部员工--</option>
		        	  	  <option value="2">服务员</option>
		        	  	  <option value="3">厨师</option>
		        	  </select>
        	 </div>
        	<!--input type="text" name="shop_name" placeholder="请输入店铺名称"  autocomplete="off" class="layui-input">-->
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <button class="layui-btn" onclick="x_admin_show('添加用户','{:url("Employee/addwaiter")}')"><i class="layui-icon"></i>添加</button>
    <table id="demo" lay-filter="test"></table>
    <script type="text/html" id="toolbarDemo">
		  <div class="layui-btn-container">
		    <button class="layui-btn layui-btn-sm" lay-event="delete">删除</button>
		    <button class="layui-btn layui-btn-sm" lay-event="update">编辑</button>
		  </div>
		</script>
		<!--<div id="demo2"></div>-->
    <script>
	layui.use(['table','layer','form','upload','laydate','laypage'], function(){
		  var table = layui.table;
		   $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer
            ,upload = layui.upload
            ,laydate = layui.laydate
            ,laypage = layui.laypage;          
     //监听工具条
			table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
					  var data = obj.data; //获得当前行数据
					  //console.log(data);
					  var id=obj.data.id;
					  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
					  //console.log(id);
					  var tr = obj.tr; //获得当前行 tr 的DOM对象
					  
						if(layEvent=='update'){
							 /*x_content_detail('修改信息','/index.php/admin/Employee/waiter_edit',id,600,500);*/
							  layer.open({
								  type: 2,
								  title :'修改信息',
								  area: ['1000px', '700px'],
								  content: '/index.php/admin/Employee/waiter_edit/id/'+id//这里content是一个普通的String
								});
						}else if(layEvent=='delete'){
							  layer.confirm('真的删除行么', function(index){
							  	  $.post('{:url("Employee/waiter_del")}',{'id':id},function(res){
							  	  	   if(res==true){
							  	  	   	    obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
												      layer.close(index);
												      //向服务端发送删除指令
							  	  	   }else{
							  	  	   	   layer.close(index); 
							  	  	   }
									  });
						      /**/
						    });
						}
			});
			var tableIns=table.render({
			    elem: '#demo'
			    ,align:'center'
			    ,where: { //设定异步数据接口的额外参数，任意设
						    'shop_id': 0,
						    'status':0,
						  }
			    ,url: '{:url("Employee/selwaiter")}' //数据接口
			    ,page: true //开启分页
			    ,toolbar: 'default'
			    ,defaultToolbar: ['filter', 'print', 'exports']
			    ,cols: [[ //表头
			      {field: 'id', title: 'ID'}
			      ,{field: 'true_name', title: '员工姓名'}
			      ,{field: 'sex', title: '性别'}
			      ,{field: 'phone', title: '电话'} 
			      ,{field: 'status', title: '身份'}
			      ,{field: 'selshop', title: '店铺名称'}
			      ,{fixed: 'right', title: '操作',align: 'center',toolbar: '#toolbarDemo'}
			    ]]
			    ,id: 'testReload'
			    ,page: {
				    curr: 1 //重新从第 1 页开始
				    ,layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
			      //,curr: 5 //设定初始在第 5 页
			      ,limit:5 //一页显示多少条
			      ,limits:[5,10,15,20,25,30]//每页条数的选择项
			      ,groups: 5 //只显示 2 个连续页码
			      ,first: "首页" //不显示首页
			      ,last: "尾页" //不显示尾页
							 }
			});
	    
			 var $ = layui.$, active = {
            reload: function(){
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: { //设定异步数据接口的额外参数，任意设
									    'shop_id': 0,
									    'status':0,
									  }
                });
            }
      };
			form.on('submit(sreach)',function(data){
			  tableIns.reload({
						 where: { //设定异步数据接口的额外参数，任意设
						    'shop_id': data.field.shop_id,
						    'status':data.field.status
						  }
					  ,align:'center'
				});
			  return false;
				  
			})  
	  
	});
	</script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>